<?php

	class EbDataHolder
	{
		var $data = array();
		
		public function __set($name,$value)
		{
			$this->setData($name,$value);
		}
		
		public function __get($name)
		{
			return $this->getData($name);
		}
		
		public function __isset($name)
		{
			return $this->containsData($name);
		}
	
		public function & removeData($name)
		{
			$retval = null;

			if (isset($this->data[$name]))
			{
				$retval =& $this->data[$name];
				unset($this->data[$name]);
			}

			return $retval;
		}	

		public function removeAllData()
		{
		    $this->data = null;
			$this->data = array();
		}
		
		public function setData($name, $value, $override = true)
		{
			if ($override || !isset($this->data[$name]))
			{
				$this->data[$name] = $value;
				return true;
			}			
			else
			{
				return false;
			}
		}
		
		public function mergeData($value, $override = true)
		{
			foreach ($value AS $key=>$value)
			{
				$this->setData($key,$value,$override);
			}
		}
		
		public function & getData($name, $default = null)
		{
			if (isset($this->data[$name]))
			{
				return $this->data[$name];
			}
			else
			{
				return $default;
			}
		}
		
		public function getAllData()
		{
			return $this->data;
		}
		
		public function containsData($name)
		{
			return isset($this->data[$name]);
		}
		
		public function lengthData()
		{
			return count($this->data);
		}
	}